package com.hfb.mashibing.alip8.interview.jvm;

import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;

public class MATTest {
    private String[] strings = new String[1000];

    public static void main(String[] args) {
        new MATTest().init();
    }
    public void init() {
        System.out.println("-----------------------------");
        Timer timer = new Timer();
        timer.schedule(new mytime(), 10000);

    }

    class mytime extends TimerTask {
        class OutOfMemoryTest {
            private  String[] strs = new String[1000_100];
            Double[] doubles = new Double[1024*1024*1024];
        }
        @Override
        public void run() {
            System.out.println("-------------mytime----------------");
            Map<String,Object> m = new HashMap<String,Object>();
            int i = 0;
            do{
                OutOfMemoryTest test = new OutOfMemoryTest();
                m.put(String.valueOf(i), test);
                i++;
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }while(i<100000);
        }
    }

}
